<?php

namespace App\Services;

use Overtrue\EasySms\EasySms;
use Overtrue\EasySms\Strategies\OrderStrategy;

class SmsService extends Service
{
    protected $easySms;

    public function __construct()
    {
        $config = [
            'timeout' => 5,
            'default' => [
                'strategy' => OrderStrategy::class,
                'gateways' => [
                    'yunpian'
                ]
            ],
            'gateways' => [
                'errorlog' => [
                    'file' => '/tmp/easy-sms.log',
                ],
                'yunpian' => [
                    'api_key' => env('SMS_YUNPIAN_API_KEY')
                ]
            ]
        ];
        $this->easySms = new EasySms($config);
    }

    public function send($phone, $data)
    {
        return $this->easySms->send($phone, $data);
    }
}